// 非常可乐
#include <iostream>
#include <vector>
#include <queue>
#define INF 0x7fffffff
using namespace std;

struct situation
{
    int coke[3];
    int times;
};

vector<struct situation> archive;
queue<struct situation> Q;
int bottles[3];

bool find(struct situation caase)
{
    for (vector<struct situation>::iterator iter = archive.begin(); iter != archive.end(); iter++)
    {
        if (caase.coke[0] == (*iter).coke[0] && caase.coke[1] == (*iter).coke[1] && caase.coke[2] == (*iter).coke[2])
        {
            return true; // if found a same situation, return true
        }
    }
    return false; // if none of the archived situation matched the input, return false
}

struct situation pour(struct situation tmp, int a, int b)
{
    struct situation tmp2;
    int freespace, liquid_to_transfer;
    int c;
    if (tmp.coke[a]) // a bottle must have coke inside to pour coke to other bottle
    {
        if (tmp.coke[b] < bottles[b]) // a bottle must be not full to receive coke
        {
            freespace = bottles[b] - tmp.coke[b];
            if (freespace <= tmp.coke[a])
            {
                liquid_to_transfer = freespace;
            }
            else
            {
                liquid_to_transfer = tmp.coke[a];
            }
            tmp2.coke[a] = tmp.coke[a] - liquid_to_transfer;
            tmp2.coke[b] = tmp.coke[b] + liquid_to_transfer;
            for (int i = 0; i < 3; i++)
            {
                if (i != a && i != b)
                {
                    c = i;
                    break;
                }
            }
            tmp2.coke[c] = tmp.coke[c];
            if (!find(tmp2))
            {
                archive.push_back(tmp2);
                tmp2.times = tmp.times + 1;
                return tmp2;
            }
        }
    }
    tmp2.times = -1;
    return tmp2;
}

int main()
{
    ios::sync_with_stdio(false);
    struct situation tmp, tmp2;
    bool found;
    while (true)
    {
        // S(0) N(1) M(2)
        cin >> bottles[0] >> bottles[1] >> bottles[2];
        if (bottles[0] == 0 && bottles[1] == 0 && bottles[2] == 0)
        {
            break;
        }
        while (!Q.empty())
        {
            Q.pop();
        }
        tmp.coke[0] = bottles[0];
        tmp.coke[1] = 0;
        tmp.coke[2] = 0;
        tmp.times = 0;
        Q.push(tmp);
        archive.push_back(tmp);
        found = false;
        while (!Q.empty())
        {
            // check whether coke have been split equally.
            tmp = Q.front();
            Q.pop();
            if (tmp.coke[0] == tmp.coke[1] && tmp.coke[0] != 0 && tmp.coke[1] != 0 && tmp.coke[2] == 0 ||
                tmp.coke[1] == tmp.coke[2] && tmp.coke[1] != 0 && tmp.coke[2] != 0 && tmp.coke[0] == 0 ||
                tmp.coke[0] == tmp.coke[2] && tmp.coke[0] != 0 && tmp.coke[2] != 0 && tmp.coke[1] == 0
                /*
                ||
                tmp.coke[0] + tmp.coke[1] = = tmp.coke[2] ||
                tmp.coke[0] + tmp.coke[2] == tmp.coke[1] ||
                tmp.coke[1] + tmp.coke[2] == tmp.coke[0]
                */
            )
            {
                found = true;
                break;
            }
            // S -> N
            tmp2 = pour(tmp, 0, 1);
            if (tmp2.times != -1)
            {
                Q.push(tmp2);
            }
            // S -> M
            tmp2 = pour(tmp, 0, 2);
            if (tmp2.times != -1)
            {
                Q.push(tmp2);
            }
            // N -> S
            tmp2 = pour(tmp, 1, 0);
            if (tmp2.times != -1)
            {
                Q.push(tmp2);
            }
            // N -> M
            tmp2 = pour(tmp, 1, 2);
            if (tmp2.times != -1)
            {
                Q.push(tmp2);
            }
            // M -> S
            tmp2 = pour(tmp, 2, 0);
            if (tmp2.times != -1)
            {
                Q.push(tmp2);
            }
            // M -> N
            tmp2 = pour(tmp, 2, 1);
            if (tmp2.times != -1)
            {
                Q.push(tmp2);
            }
        }
        if (found)
        {
            cout << tmp.times << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    return 0;
}